'use strict'

/*
|--------------------------------------------------------------------------
| Routes
|--------------------------------------------------------------------------
|
| Http routes are entry points to your web application. You can create
| routes for different URLs and bind Controller actions to them.
|
| A complete guide on routing is available here.
| http://adonisjs.com/docs/4.1/routing
|
*/

/** @type {typeof import('@adonisjs/framework/src/Route/Manager')} */
const Route = use('Route')
const { AliYunService } = require('../app/Services')


/*---------------------- 获取微信jsconfig START ----------------------*/
const WechatAPI = require('co-wechat-api')
const api = new WechatAPI('wx93c46cc47e47e956', '48070de4fddf001f61c6fa2b4be82628')
Route.any('/jsconfig', async ({ request, response }) => {
  let { url } = request.all()
  let param = {
    debug: false,
    jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'],
    url
  }
  response.json(await api.getJsConfig(param))
})
/*---------------------- 获取微信jsconfig END ----------------------*/

Route.get('/', async () => {
  // await AliYunService.sendSMS(
  //   17621196032,
  //   'SMS_165415774',
  //   {
  //     code: 4213
  //   }
  // )
  return { greeting: 'Hello world in JSON' }
})
require('../app/routes_h5.js')
require('../app/routes_admin.js')
Route.get('driveTable', ({ view }) => {
  return view.render('driveTable')
})
